<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .div{
            width: 1000px;
            height: 500px;
            border: 1px solid black;
            margin: 0 auto;
        }
        .tab{
            width: 800px;
            height: 50px;
            margin: 0 auto;
            border: 1px solid red;
        }
        .tab-list{
            width: 800px;
            height: 400px;
            margin: 0 auto;
            margin-top: 10px;
            border: 1px solid blue;

        }
        .tab ul li{
            float: left;
            display: inline;
            width: 200px;
            text-align: center;
            line-height: 50px;
            background-color: rgb(190, 190, 163);
        }
        .tab-list ul li{
            display: none;
        }
        .tab-list ul .cur{
            display: block;
        }
    </style>
</head>
<body>
    <div class="div">
        <div class="tab">
            <ul>
                <li>1</li>
                <li>2</li>
                <li>3</li>
                <li>4</li>
            </ul>
        </div>
        <div class="tab-list">
            <ul>
                <li class="cur">1111111</li>
                <li>22222222222</li>
                <li>333333333333333</li>
                <li>444444444444</li>
            </ul>
        </div>
    </div>
</body>
<script>
    var tab = document.querySelector('.tab');
    var tabUl = tab.querySelector('ul');
    var tabLi = tabUl.querySelectorAll('li');
    var tabList = document.querySelector('.tab-list');
    var tabListUl = tabList.querySelector('ul');
    var tabListLi = tabListUl.querySelectorAll('li');
    for(var i = 0; i < tabLi.length; i++){
        tabLi[i].onclick = function(){ 
            for(var j = 0;j<tabListLi.length;j++){
                tabListLi[j].className = '';
                // tabLi[j].className = '';
            }
            tabListLi[i].className = 'cur';
            console.log(i);
            
        }
    }
</script>
</html>